package com.only4play.practice.invoice.core.entity;

import com.only4play.codegen.processor.api.*;
import com.only4play.codegen.processor.controller.GenController;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.dto.GenDto;
import com.only4play.codegen.processor.entitymapper.GenObjectMapper;
import com.only4play.codegen.processor.mapper.GenMapper;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.service.GenService;
import com.only4play.codegen.processor.service.GenServiceImpl;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.codegen.support.model.BaseEntity;

import com.only4play.practice.common.enums.invoice.InvoiceKind;
import com.only4play.practice.common.enums.invoice.InvoiceType;
import com.only4play.practice.common.enums.TitleType;
import com.only4play.codegen.support.annotation.FieldDesc;
import com.only4play.codegen.support.constants.ValidStatus;
import com.only4play.practice.common.other.CodeValue;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@GenCreator(pkgName = "com.only4play.practice.invoice.api.model.creator")
@GenUpdater(pkgName = "com.only4play.practice.invoice.api.model.updater")
// findById方法
@GenVo(pkgName = "com.only4play.practice.invoice.api.model.vo")
// findByPage方法
@GenQuery(pkgName = "com.only4play.practice.invoice.api.model.query")
@GenCreateRequest(pkgName = "com.only4play.practice.invoice.model.api.request")
@GenUpdateRequest(pkgName = "com.only4play.practice.invoice.model.api.request")
@GenQueryRequest(pkgName = "com.only4play.practice.invoice.model.api.request")
@GenResponse(pkgName = "com.only4play.practice.invoice.api.model.api.response")
@GenDto(pkgName = "com.only4play.practice.invoice.model.dto")
// 生成serviceImpl
@GenObjectMapper(pkgName = "com.only4play.practice.invoice.core.entitymapper")
// 生成serviceImpl
@GenMapper(pkgName = "com.only4play.practice.invoice.core.mapper")
@GenService(pkgName = "com.only4play.practice.invoice.core.service")
@GenServiceImpl(pkgName = "com.only4play.practice.invoice.core.service.impl")

@GenController(pkgName = "com.only4play.practice.invoice.core.controller")
@GenFeign(pkgName = "com.only4play.practice.invoice.feign")

@Data
public class Invoice extends BaseEntity {

  @FieldDesc(name = "发票类型")
  private InvoiceType invoiceType;

  @FieldDesc(name = "发票种类")
  private InvoiceKind invoiceKind;

  @FieldDesc(name = "抬头类型")
  private TitleType titleType;

  @FieldDesc(name = "批次号")
  private String batchNo;

  @FieldDesc(name = "第几张发票")
  private Integer indexNo;

  @FieldDesc(name = "申请渠道编码")
  private String applyChannelNo;

  @FieldDesc(name = "发票金额")
  private BigDecimal invoiceAmount;

  @FieldDesc(name = "金税申请流水")
  private String applyFlowNo;

  /**
   * 销方开票主体
   */
  @FieldDesc(name = "名称")
  private String sellerName;

  @FieldDesc(name = "纳税人识别号")
  private String sellerTaxNo;

  @FieldDesc(name = "地址")
  private String sellerAddress;

  @FieldDesc(name = "电话")
  private String sellerPhone;

  @FieldDesc(name = "销方开户银行")
  private String sellerOpenBank;

  @FieldDesc(name = "销方账号")
  private String sellerAccount;

  @FieldDesc(name = "税务编码")
  private String taxCode;

  /**
   * 操作人信息
   */
  @FieldDesc(name = "开票人")
  private String drawer;

  @FieldDesc(name = "复核人")
  private String reviewer;

  @FieldDesc(name = "收款人")
  private String payee;

  /**
   * 客户信息
   */

  @FieldDesc(name = "名称")
  private String customerName;

  @FieldDesc(name = "纳税人识别号")
  private String customerTaxNo;

  @FieldDesc(name = "客户地址")
  private String customerAddress;

  @FieldDesc(name = "客户电话")
  private String customerPhone;

  @FieldDesc(name = "客户开户银行")
  private String customerOpenBank;

  @FieldDesc(name = "客户银行账号")
  private String customerAccount;

  private ValidStatus validStatus;

  @FieldDesc(name = "开票时传递的扩展属性信息")
  private List<CodeValue> extAttrs;




  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid() {
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid() {
    setValidStatus(ValidStatus.INVALID);
  }

}
